#pragma once
#include "Buffer.h"
#include <vector>

class IndexBuffer : public Buffer
{
  uint32_t m_type = 0;

  template <typename T>
  int32_t GetSizeType()
  {
    switch (sizeof(T))
    {
    case 1:
      return GL_UNSIGNED_BYTE;
    case 2:
      return GL_UNSIGNED_SHORT;
    case 4:
      return GL_UNSIGNED_INT;
    }

    assert(false);
    return 0;
  }

public:
  template <typename T>
  IndexBuffer(T _) : Buffer(GL_ELEMENT_ARRAY_BUFFER)
  {
    static_assert(
        std::is_same<T, uint8_t>::value || std::is_same<T, uint16_t>::value || std::is_same<T, uint32_t>::value,
        "The given type must be either unsigned char, unsigned short or unsigned int");
    m_type = GetSizeType<T>();
  }

  uint32_t GetType() const { return m_type; }
};